<!--@extends("layout.main")-->

@section("content")
    @include("layout.nav")
<div class="layui-container">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md8">
            @if(request('page')<=1)
            <div class="fly-panel">
                <div class="fly-panel-title fly-filter">
                    <a>置顶</a>
                    <a href="#signin" class="layui-hide-sm layui-show-xs-block fly-right" id="LAY_goSignin"
                       style="color: #FF5722;">去签到</a></div>
                <ul class="fly-list">
                    @foreach($topQuestion as $question)
                        <li>
                            <a href="/user/{{$question->user->id}}" class="fly-avatar">
                                <img src="{{$question->user->face}}" alt="空白处"></a>
                            <h2>
                                <a class="layui-badge">{{$question->cate->name}}</a>
                                <a href="/question/{{$question->id}}/show">{{$question->title}}</a></h2>
                            <div class="fly-list-info">
                                <a href="/user/{{$question->user->id}}" link>
                                    <cite>{{$question->user->name}}</cite></a>
                                <span>{{$question->created_at->diffForHumans()}}</span>
                                <span class="fly-list-kiss layui-hide-xs" title="悬赏飞吻">
                                        <i class="iconfont icon-kiss"></i>{{$question->kiss}}</span>
                                <span class="fly-list-nums">
                                        <i class="iconfont icon-pinglun1" title="回答"></i>{{count($question->answers)}}</span>
                            </div>
                            <div class="fly-list-badge"></div>
                        </li>
                    @endforeach
                </ul>
            </div>
            @endif
            <div class="fly-panel" style="margin-bottom: 0;">
                <div class="fly-panel-title fly-filter">
                    <a href="{:url('index/question/qlist',['cid'=>input('cid')])}" class="layui-this">综合</a>
                    <span class="fly-mid"></span>
                    <a href="{:url('index/question/qlist',['cid'=>input('cid'),'ststus'=>'notover']);}">未结</a>
                    <span class="fly-mid"></span>
                    <a href="{:url('index/question/qlist',['cid'=>input('cid'),'status'=>'over']);}">已结</a>
                    <span class="fly-mid"></span>
                    <a href="{:url('index/question/qlist',['cid'=>input('cid'),'status'=>'jing']);}">精华</a></div>
                <ul class="fly-list">
                    @foreach($questions as $question)
                    <li>
                        <a href="/user/{{$question->user->id}}" class="fly-avatar">
                            <img src="{{$question->user->face}}" alt="空白处"></a>
                        <h2>
                            <a class="layui-badge">{{$question->cate->name}}</a>
                            <a href="/question/{{$question->id}}/show">{{$question->title}}</a></h2>
                        <div class="fly-list-info">
                            <a href="/user/{{$question->user->id}}" link>
                                <cite>{{$question->user->name}}</cite></a>
                            <span>{{$question->created_at->diffForHumans()}}</span>
                            <span class="fly-list-kiss layui-hide-xs" title="悬赏飞吻">
                                        <i class="iconfont icon-kiss"></i>{{$question->kiss}}</span>
                            <span class="fly-list-nums">
                                        <i class="iconfont icon-pinglun1" title="回答"></i>{{count($question->answers)}}</span>
                        </div>
                        <div class="fly-list-badge"></div>
                    </li>
                    @endforeach
                </ul>
                <div id="pull_right">
                    <div class="pull-right">
                        {{$questions->links()}}
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-col-md4">
            <div class="fly-panel">
                <h3 class="fly-panel-title">温馨通道</h3>
                <ul class="fly-panel-main fly-list-static">
                    @foreach($wenxinQuestion as $question)
                    <li>
                        <a href="/question/{{$question->id}}/show" target="_blank">{{$question->title}}
                        </a>
                    </li>
                    @endforeach
                </ul>
            </div>
            <div class="fly-panel fly-signin">
                <div class="fly-panel-title">签到
                    <i class="fly-mid"></i>
                    <a href="javascript:;" class="fly-link" id="LAY_signinHelp">说明</a>
                    <i class="fly-mid"></i>
                    <a href="javascript:;" class="fly-link" id="LAY_signinTop">活跃榜
                        <span class="layui-badge-dot"></span></a>
                    <span class="fly-signin-days"></span>
                </div>
                <div class="fly-panel-main fly-signin-main">
                    @if(\Auth::user())
                    <button class="layui-btn @if($theuser->theSign()) layui-btn-danger @else layui-btn-disabled @endif " id="LAY_signin">今日签到</button>
                    @else
                        <button class="layui-btn  layui-btn-danger " id="LAY_signin">今日签到</button>
                    @endif
                </div>
            </div>
            <div class="fly-panel">
                <div class="fly-panel-title">钻级赞助商
                    <span class="fly-mid"></span>
                    <a href="/jie/15697/" class="fly-link fly-joinad    ">我要加入</a></div>
                <div class="fly-panel-main" style="padding: 13px 15px;">
                    <a href="/jie/15697/" target="_blank" rel="nofollow" class="fly-zanzhu"
                       style="background-color: #393D49;">虚席以待</a></div>
            </div>
            <div class="fly-panel fly-rank fly-rank-reply" id="LAY_replyRank">
                <h3 class="fly-panel-title">回贴周榜</h3>
                <dl>
                    @foreach($users as $user)
                    <dd>
                        <a href="/user/{{$user->id}}">
                            <img src="{{$user->face}}">
                            <cite>{{$user->name}}</cite>
                            <i>{{count($user->answer)}}次回答</i>
                        </a>
                    </dd>
                    @endforeach
                </dl>
            </div>
            <dl class="fly-panel fly-list-one">
                <dt class="fly-panel-title">本周热议</dt>
                @foreach($hotQuestions as $question)
                <dd>
                    <a href="/question/{{$question->id}}/show">{{$question->title}}</a>
                    <span>
                                <i class="iconfont icon-pinglun1"></i>{{$question->answers_count}}</span>
                </dd>
                @endforeach

            </dl>
            <div class="fly-panel">
                <div class="fly-panel-title">官方产品</div>
                <div class="fly-panel-main">
                    <a href="#" target="_blank" class="fly-zanzhu"
                       time-limit="2017.09.25-2099.01.01" style="background-color: #5FB878;">LayIM 3.0 - layui 旗舰之作</a>
                </div>
            </div>
            <div class="fly-panel" style="padding: 20px 0; text-align: center;">
                <img  style="max-width: 100%;"
                     alt="layui">
                <p style="position: relative; color: #666;">微信扫码关注 layui 公众号</p></div>
            <div class="fly-panel fly-link">
                <h3 class="fly-panel-title">友情链接</h3>
                <dl class="fly-panel-main">
                    @foreach($links as $link)
                    <dd>
                        <a href="{{$link->url}}" target="_blank">{{$link->name}}</a>
                    <dd>

                     @endforeach
                </dl>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['layer','jquery'], function(){
        var $ = layui.jquery;
        var layer = layui.layer;
        $('.fly-search').click(function () {
            layer.open({
                type: 1,
                title: false,
                closeBtn: 0,
                shadeClose: true,
                area: ['550px'], //宽高
                skin: ' fly-layer-search',
                content: '<form action="/search"><input autocomplete="off" placeholder="搜索内容，回车跳转" type="text" name="q"></form>'
            });
        })
        $('.layui-btn-danger').click(function () {
            that = $(this);
            if({{!\Auth::user()}}){
                layer.msg('请先登录', function(){
                });
            }
            $.ajax({
                url:"/sign",
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    if(data.error ==1){
                        layer.msg(data.info, function(){
                            that.addClass('layui-btn-disabled').removeClass('layui-btn-danger')
                        });
                    }else if(data.error ==0){
                        layer.alert(data.info, {icon: 6},function(){
                            that.addClass('layui-btn-disabled').removeClass('layui-btn-danger')
                        });
                    }
                },
                fail: function (err) {
                    console.log(err)
                }
            })
        })

    });
</script>
@endsection
